package datastructures;

import java.util.BitSet;

public class Individual {
	
	public static int count =0;
	private IndividualInfo info;
	private final BitSet genotypeVariables;
	
	public Individual(String FAM_ID, String IND_ID, String PAT_ID, String MAT_ID, String sex, String phenotype, int numberOfSNPs, BitSet genotypeBitSet)
	{	
		this.info = new IndividualInfo(FAM_ID, IND_ID, PAT_ID, MAT_ID, sex, phenotype, numberOfSNPs); 
		this.genotypeVariables = (BitSet) genotypeBitSet.clone();
	}
	
	public Individual(IndividualInfo indInfo, BitSet genotypeBitSet)
	{	
		this.info = indInfo;
		this.genotypeVariables = genotypeBitSet;
	}

	public IndividualInfo getIndividualInfo() {
		return info;
	}

	public void setIndividualInfo(IndividualInfo indivInfo) {
		info = indivInfo;
	}
	
	public BitSet getGenotype() {
		return genotypeVariables;
	}
	
	public String toString() {
		StringBuffer indiv = new StringBuffer( 
				info.getFAM_ID() + "\t" + 
				info.getIND_ID() + "\t" + 
				info.getMAT_ID() + "\t" + 
				info.getPAT_ID() + "\t" + 
				info.getSex() +"\t" + 
				info.getPhenotype());
		
		int minallelecount;
		for(int snp=0; snp<info.getNumberOfSNPs(); snp++) {
			minallelecount = 0;
			if(genotypeVariables.get(2*snp + 1))
				minallelecount = 2;
			else if(genotypeVariables.get(2*snp))
				minallelecount = 1;	
			indiv.append("\t"+minallelecount);
		}
		
		return indiv.toString();
	}
	
}
